import Notify from '@vant/weapp/notify/notify';
const curd = getApp().curd;
Component({
  properties: {

  },
  data: {
    value: '',
    list: []
  },
  methods: {
    // 监听input输入更新value
    onChange(event) {
      this.setData({
        value: event.detail
      })
    },
    // 新增一项待办
    addTodo() {
      const content = this.data.value;
      if (content === '') { return }
      curd.create('list', { content, state: false }, () => {
        this.triggerEvent("update");
        Notify({
          message: '加油呀💪',
          color: '#fff',
          background: 'rgba(83, 224, 116, 1)',
          duration: 800
        });
      });
      this.setData({
        value: ''
      })
    }
  }
})
